[Leetcode] 711. Number of Distinct Islands II 解题报告

这篇博客探讨了LeetCode上的711题,即计算非空二维数组中不同岛屿的数量。岛屿是由1组成的四向连接的群体,四周被0包围。岛屿被认为是相同的,如果它们形状相同,或者经过90、180或270度旋转或水平/垂直翻转。博主通过DFS方法解决此问题,重点在于处理岛屿的旋转和反射。每发现一个岛屿,会生成其8种变形,并选择排序最小的形式作为代表。解决方案借鉴了694题的思路。
摘要由CSDN通过智能技术生成

题目

Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water.

Count the number of distinct islands. An island is considered to be the same as another if they have the same shape, or have the same shape after rotation (90, 180, or 270 degrees only) or reflection (left/right direction or up/down direction).

Example 1:

11000
10000
00001
00011
Given the above grid map, return  1
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值